using Microsoft.VisualBasic.CompilerServices;
using SJVars;
using System;
using System.Reflection;
using System.Windows.Forms;
using yW5Lib;

namespace yWriter6
{
	[StandardModule]
	public sealed class modEditLocation
	{
		public static bool EditLocation(ref clsProject cProject, int LocationID, int WhichTab = 0)
		{
			bool result = false;
			try
			{
				frmEditLocation frmEditLocation = new frmEditLocation();
				frmEditLocation.Edit(ref cProject, LocationID, WhichTab);
				result = frmEditLocation.Saved;
				cProject.QuickSave();
				return result;
			}
			catch (Exception ex)
			{
				ProjectData.SetProjectError(ex);
				Exception ex2 = ex;
				clsShared.cLog.AddAction(ex2, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
				return result;
			}
		}

		public static bool AddEditLocations(ref clsProject cProject, bool ShowChooser)
		{
			if (new frmList(ref cProject, eRecord.eLocation).ShowDialog(ShowChooser) == DialogResult.OK)
			{
				return true;
			}
			bool result = default(bool);
			return result;
		}

		public static bool AddNewLocation(ref clsProject cProject)
		{
			bool result = false;
			int num = cProject.AddNewLocation();
			if (!EditLocation(ref cProject, num))
			{
				cProject.RemoveLocationByID(num);
			}
			else
			{
				result = true;
			}
			return result;
		}
	}
}
